﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Practice_six
{
    public partial class Homework06 : Form
    {



        public Homework06()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //获取标签值
            int Num01 = Convert.ToInt32(this.label9.Text);
            int Num02 = Convert.ToInt32(this.label10.Text);
            int Num03 = Convert.ToInt32(this.label11.Text);
            int Num04 = Convert.ToInt32(this.label12.Text);
            if (rbtn_01.Checked)
            {
                click_vote(label5,label9, Num01);
            }
            else if (rbtn_02.Checked) 
            {
                click_vote(label6, label10, Num02);
            }
            else if (rbtn_03.Checked)
            {
                click_vote(label7, label11, Num03);
            }
            else
            {
                click_vote(label8, label12, Num04);
            }
        }

        //优化
        private void click_vote(System.Windows.Forms.Label label01, System.Windows.Forms.Label label02 , int Num)
        {
            label02.Text = Convert.ToString(Num + 1);
            //获取label的高度和宽度
            int width = label01.Size.Width;
            int height = label01.Size.Height;
            //触发点击事件,label的长度增长
            label01.Size = new System.Drawing.Size(width + 5, height);
        }
    }
}
